class CommentsController < ApplicationController  
  require 'net/http'
	def create
		@comment = Comment.new(params[:comment])
		@page = @comment.page
		if @comment.save
		  @url_name = url_for(:controller => :home, :action => :index).to_s
		  begin
        @comment.send_email(@page,@url_name)
      rescue Timeout::Error
        flash[:notice] = "Email Server is not responding.  Please send email manually."
      end  
			redirect_to page_path(@comment.page_id)
		else
			flash[:notice] = "Empty comments are bad!"
			redirect_to page_path(@comment.page_id)
		end
	end
end
